package com.net.wanjian.networkhospitalmanager.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.adapter.base.RecyclerBaseAdapter;
import com.net.wanjian.networkhospitalmanager.bean.teacherevent.SearchEducatiationByConditionResult;
import com.net.wanjian.networkhospitalmanager.utils.URLDecoderUtil;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Description:
 * Created by lidongcai on 17/5/26.
 * Email:  lidongcaiocc@163.com
 */

public class TeacherEventAdapter extends RecyclerBaseAdapter<SearchEducatiationByConditionResult.DataBean.EducationActivityListBean, TeacherEventAdapter.ViewHolder> {

    public TeacherEventAdapter(Context context) {
        super(context);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_teacher_event_list, parent, false);
        AutoUtils.auto(view);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, SearchEducatiationByConditionResult.DataBean.EducationActivityListBean item, int position) {
        holder.setItemTeacherEventLessonNameTv(URLDecoderUtil.getDecoder(item.getEducationActivityName()));
        holder.setItemTeacherEventMainSpeakTv("主讲人："+URLDecoderUtil.getDecoder(item.getTrueName()));
        if (!URLDecoderUtil.getDecoder(item.getDepartmentName()).equals("")){
            holder.setItemTeacherEventDepartmentRoomTv("科室："+URLDecoderUtil.getDecoder(item.getDepartmentName())+" "+"房间："+URLDecoderUtil.getDecoder(item.getRoomName()));
        }else {
            holder.setItemTeacherEventDepartmentRoomTv("科室：未分配"+" "+"房间："+URLDecoderUtil.getDecoder(item.getRoomName()));
        }
        holder.setItemTeacherEventTimeTv(URLDecoderUtil.getDecoder(item.getEducationActivityTime()));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_teacher_event_lesson_name_tv)
        TextView itemTeacherEventLessonNameTv;
        @BindView(R.id.item_teacher_event_department_room_tv)
        TextView itemTeacherEventDepartmentRoomTv;
        @BindView(R.id.item_teacher_event_main_speak_tv)
        TextView itemTeacherEventMainSpeakTv;
        @BindView(R.id.item_teacher_event_time_tv)
        TextView itemTeacherEventTimeTv;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        //设置值的方法

        public void setItemTeacherEventLessonNameTv(String itemTeacherEventLessonNameTv) {
            this.itemTeacherEventLessonNameTv.setText(itemTeacherEventLessonNameTv);
        }

        public void setItemTeacherEventDepartmentRoomTv(String itemTeacherEventDepartmentRoomTv) {
            this.itemTeacherEventDepartmentRoomTv.setText(itemTeacherEventDepartmentRoomTv);
        }

        public void setItemTeacherEventMainSpeakTv(String itemTeacherEventMainSpeakTv) {
            this.itemTeacherEventMainSpeakTv.setText(itemTeacherEventMainSpeakTv);
        }

        public void setItemTeacherEventTimeTv(String itemTeacherEventTimeTv) {
            this.itemTeacherEventTimeTv.setText(itemTeacherEventTimeTv);
        }
    }
}
